{% extends 'base/base.html' %}

{% block title %}监测类别管理 - 环保监测数据管理系统{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h2">监测类别管理</h1>
        <div>
            <a href="{% url 'monitoring:category_create' %}" class="btn btn-primary">
                <i class="fas fa-plus"></i> 添加类别
            </a>
        </div>
    </div>
    
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">监测类别列表</h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered table-hover">
                    <thead class="table-light">
                        <tr>
                            <th>ID</th>
                            <th>类别名称</th>
                            <th>描述</th>
                            <th>数据数量</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for category in categories %}
                        <tr>
                            <td>{{ category.id }}</td>
                            <td>{{ category.name }}</td>
                            <td>{{ category.description|default:"无" }}</td>
                            <td>{{ category.data_count }}</td>
                            <td>{{ category.created_at|date:"Y-m-d H:i" }}</td>
                            <td>
                                <a href="{% url 'monitoring:category_update' category.id %}" class="btn btn-sm btn-primary">
                                    <i class="fas fa-edit"></i> 编辑
                                </a>
                                <a href="{% url 'monitoring:category_delete' category.id %}" class="btn btn-sm btn-danger">
                                    <i class="fas fa-trash"></i> 删除
                                </a>
                            </td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="6" class="text-center">暂无监测类别</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %} 